﻿Imports WMPLib
Public Class DiaShowForm

  Dim _w As WallpaperService = ServiceManager.GetServiceManager.GetWallpaperService
  Dim _wallpapers As List(Of Wallpaper)
  Dim _ids As List(Of Integer)

  Dim _i As Integer = 0

  Private Sub BeendenButton_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BeendenButton.Click
    Timer1.Stop()
    Close()
  End Sub

  Public Shadows Sub showdialog(ByVal wallpaper As List(Of Integer))
    Me.BeendenButton.BackColor = Color.Black
    _ids = wallpaper
    'AxWindowsMediaPlayer1.URL = "E:\Musik\Dilated Peoples - Expansion Team - 2001. by darkjore\03 - Clockwork.mp3"
    AxWindowsMediaPlayer1.URL = "E:\lollipopp.mp3"
    
    Timer1.Start()
    MyBase.ShowDialog()
  End Sub

  Private Sub Timer1_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer1.Tick
    Try
      Me.PictureBox1.ImageLocation = Configuration.GetObject.SkinsPath & _w.GetWallpaperById(_ids(_i)).Filename
      Refresh()
      _i += 1
      If _i = _ids.Count Then
        _i = 0
      End If
      Refresh()
    Catch ex As ArgumentOutOfRangeException
      MsgBox("Keine Bilder gefunden", MsgBoxStyle.Critical)
      Timer1.Stop()
      Close()
    End Try
  End Sub

  Private Sub TextBox1_TextChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged
    Dim i As Integer
    If Integer.TryParse(TextBox1.Text, i) Then
      Me.Timer1.Stop()
      Me.Timer1.Interval = i
      Me.Timer1.Start()
    End If
  End Sub

  Private Sub DiaShowForm_SizeChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.SizeChanged
    Me.PictureBox1.Size = New Size(Me.Width - 200, Me.Height - 100)
    Me.Location = New Point(300, 20)
    Me.AxWindowsMediaPlayer1.Size = New Size(Me.PictureBox1.Size.Width, Me.AxWindowsMediaPlayer1.Height)
    Me.AxWindowsMediaPlayer1.Location = New Point(150, 30 + Me.PictureBox1.Height)
    Refresh()
  End Sub
End Class